package com.united.ucts.modules.monitor.pojo;

import cn.hutool.core.util.NumberUtil;
import com.united.frame.common.module.pojo.dto.BaseDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * 自定义的服务器CPU信息类
 *
 * @author hudan
 * @version 1.0
 * @filename Cpu.java
 * @copyright www.united.com
 * @date 2019/7/22
 */
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class Cpu extends BaseDto {

    @ApiModelProperty(value = "CPU核心数")
    private Integer cpuNum;
    @ApiModelProperty(value = "CPU总的使用率")
    private double total;
    @ApiModelProperty(value = "CPU系统使用率")
    private double sys;
    @ApiModelProperty(value = "CPU用户使用率")
    private double used;
    @ApiModelProperty(value = "CPU当前等待率")
    private double wait;
    @ApiModelProperty(value = "CPU当前空闲率")
    private double free;

    public int getCpuNum() {
        return cpuNum;
    }

    public double getTotal() {
        return NumberUtil.round(NumberUtil.mul(total, 100), 2).doubleValue();
    }

    public double getSys() {
        return NumberUtil.round(NumberUtil.mul(sys / total, 100), 2).doubleValue();
    }

    public double getUsed() {
        return NumberUtil.round(NumberUtil.mul(used / total, 100), 2).doubleValue();
    }

    public double getWait() {
        return NumberUtil.round(NumberUtil.mul(wait / total, 100), 2).doubleValue();
    }

    public double getFree() {
        return NumberUtil.round(NumberUtil.mul(free / total, 100), 2).doubleValue();
    }
}